#!/bin/bash -e

function info() {
echo Usage: `basename $0` 'beta_test fa header'
exit 1
}

while getopts  ":p:f:" opt; do
	case  $opt  in
		p) out_prefix=$OPTARG;;
		f) suffix=$OPTARG;;
		*) info;;
	esac
done
shift $(($OPTIND - 1))


if [ $# -lt 3 ]; then info; fi

. $var

header=$3
fa=$2

beta2seq.py -i $header $1

sed -i 1d atcg.txt

beta2fq.py atcg.txt

bwa mem -B1 -O3,6 -E1,2 -L100 -T20 -a $fa 1.beta.fq > sam
# bwa mem -B1 -O3,6 -E1,2 -L100 -T20 $fa 1.beta.fq > sam

aln=aln_score
echo >> $aln
echo >> $aln
echo $@ >> $aln

grep '^test' sam |cut -f3|cut -f1 -d_|sort|uniq -c|sed 's/^  *//; s/ /\t/' |sort -k1,1nr |head -6 >> $aln

# bwa mem -B0 -e -M 

# bwa mem -A2 -B1 -L10

 
 # T quality to output
 # -a output all
 # -L clip penalty
 # -E gap extend penalty
 # -O gap open penalty
 # -B mismathc penalty

# -O If two numbers are specified, the first is  the  penalty of openning a deletion and the second for openning an insertion.
# -w gaps  longer than INT will not be found

. $cmd_done